package com.guo.hui.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guo.hui.dao.ponal.CateMapper;
import com.guo.hui.enumtype.DelFlag;
import com.guo.hui.model.ponal.Cate;
import com.guo.hui.page.PageParam;
import com.guo.hui.service.ResumeCateService;
import com.guo.hui.util.UtilDate;

@Service("resumeCateService")
public class ResumeCateServiceImpl implements ResumeCateService {

	@Autowired
	private CateMapper cateDao;

	@Override
	public void saveCate(Cate cate) {
		String time = UtilDate.datetoString(new Date(), "yyyy-MM-dd");// 日期转化字符串
		cate.setCreateDate(time);
		cate.setDelflag(DelFlag.AVIABLE.toString());
		cate.setModifyDate(new Date());
		cateDao.insert(cate);
	}

	@Override
	public void updateCate(Cate cate) {
		cate.setModifyDate(new Date());
		cateDao.update(cate);

	}

	@Override
	public PageInfo<Cate> selectByMapPage(PageParam pageParm) {
		PageHelper.startPage(pageParm.getPage(), pageParm.getPageSize());
		List<Cate> list = cateDao.selectByMap(pageParm.getSearchContent());
		return new PageInfo<Cate>(list);
	}

}
